package com.atguigu.springcloud;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import org.junit.jupiter.api.Test;

import java.util.Collections;

public class MBPGenerator {
    @Test
    public void generate() {
        final String url = "jdbc:mysql://localhost:3306/cloud?characterEncoding=utf8&rewriteBatchedStatements=true";
        String pkgPath = System.getProperty("user.dir") + "/src/main/java";
        FastAutoGenerator.create(url, "root", "971008cx")
                .globalConfig(builder -> {
                    builder.author("tjf") // 设置作者
                            .fileOverride() // 覆盖已生成文件
                            .outputDir(pkgPath); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.atguigu.springcloud"); // 设置父包名
                })
                .strategyConfig(builder -> {
                    builder.addInclude("payment"); // 设置需要生成的表名
                })
                .execute();
    }
}
